package com.yanqu.road.server.cmd.activity.shuihu;

import com.yanqu.road.pb.activity.ShuiHuActivityProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import io.netty.channel.ChannelHandlerContext;

@Cmd(code = GameProtocol.S_SHUIHU_ACTIVITY_SYNC_DRAW_CARD, desc = "跨服同步的抽卡数据")
public class ShuiHuSyncDrawCardFromCrossCmd implements Command {

    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {
        ShuiHuActivityProto.SyncDrawCardDataRespMsg reqMsg = ShuiHuActivityProto.SyncDrawCardDataRespMsg.parseFrom(packet.getBytes());

        ShuiHuActivityProto.SyncDrawCardDataRespMsg.Builder builder = reqMsg.toBuilder();
        // 发送给抽卡人以外的在线玩家
        for (GamePlayer player : GamePlayerMgr.getAllOnlinePlayer()) {
            player.sendPacket(ClientProtocol.U_SHUIHU_ACTIVITY_SYNC_DRAW_CARD, builder);
        }
    }
}
